﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Pibby.Core;
using Pibby.Core.Feeds;

namespace Pibby.Controls
{
	public class EpisodeListViewItem : System.Windows.Forms.ListViewItem
	{
		public EpisodeListViewItem(Episode e)
		{
			base.Text = e.Name;
			base.ImageIndex = 0;
			this.DbKey = e.PrimaryKey.Value;

			base.SubItems.Add(new ListViewDurationSubItem (e.Duration)); 
			base.SubItems.Add(new ListViewDateSubItem(e.PublicationDate));

			// let's make it obvious this item has been processed
			if (e.Stage == EpisodeLifecycle.Downloaded || e.Stage == EpisodeLifecycle.Transferred)
			{
				base.ForeColor = System.Drawing.Color.LawnGreen;
			}
		}

		public int DbKey
		{
			get;
			private set;
		}
	}


	public class AgedEpisodeListViewItem : EpisodeListViewItem
	{
		public AgedEpisodeListViewItem(Episode e)
			: base(e)
		{
			HslColor color = new HslColor(System.Drawing.Color.Black);

			if (e.Age == EpisodeAge.BrandNew)
				base.Font = new System.Drawing.Font(this.Font, System.Drawing.FontStyle.Bold);
			else if (e.Age == EpisodeAge.Newish)
				base.ForeColor = color.Lighten(0.15).ToColor();
			else if (e.Age == EpisodeAge.Recent)
				base.ForeColor = color.Lighten(0.3).ToColor();
			else if (e.Age == EpisodeAge.BackCatalog)
				base.ForeColor = color.Lighten(0.5).ToColor();

			base.SubItems.Add(string.IsNullOrEmpty(e.PodcastName) ? "-" : e.PodcastName);
		}

	}

}

